<?php 
	class model_page extends CI_model{
		
		function get_news($id_language, $limit){
			$q = $this->db->query("SELECT n.id_news, n.id_kategori_sub, n.url_gambar_news, nl.judul_news, nl.content_news, DATE_FORMAT(n.date_update,'%d %b %Y') as 'date_update' 
								   FROM
								   setting s
								   JOIN
								   news n ON s.id_table=n.id_kategori_sub
								   JOIN
								   news_language nl ON n.id_news=nl.id_news
								   WHERE
								   s.key='news_utama' AND nl.id_language=$id_language
								   ORDER BY n.date_update DESC LIMIT $limit");

			return $q->result();
		}

		function get_page_view($id_language, $id){
			$q = $this->db->query("SELECT * 
								   FROM
								   page p
								   JOIN
								   page_language pl ON p.id_page=pl.id_page
								   WHERE
								   pl.id_language=$id_language
								   AND p.id_page=$id");

			return $q->result();
		}

		function get_page_mod($id_language,$set,$setw){
			$q = $this->db->query("SELECT * FROM
									setting s
									INNER JOIN setting_website sw ON s.id_table=sw.id_kategori_sub
									INNER JOIN setting_website_language swl ON sw.id_setting_website=swl.id_setting_website
									WHERE
									s.key='$set' AND sw.key='$setw' AND swl.id_language='$id_language'");

			return $q->result();
		}

	}

?>